<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">

<head>
  <title></title>
  <meta charset="utf-8">
  <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  <link rel="stylesheet" href="css/fonts/font-awesome.min.css">
  <link rel="stylesheet" href="css/ui-box.css">
  <link rel="stylesheet" href="css/ui-base.css">
  <link rel="stylesheet" href="css/ui-color.css">
  <link rel="stylesheet" href="css/appcan.icon.css">
  <link rel="stylesheet" href="css/appcan.control.css">
  <link rel="stylesheet" href="css/BaggageTrace.css">
  <link rel="stylesheet" href="css/base.css">
</head>

<body class="um-vp bcF8F8F8" ontouchstart>

  <main class="bcFFF fs9">
    <ul id="BaggageList" class="BaggageList">
    </ul>
  </main>
</body>
<script src="js/appcan.js"></script>
<script src="js/appcan.control.js"></script>
<script src="js/z_API.js"></script>
<script>
  appcan.ready(function() {
    var bagStatusArr = JSON.parse(appcan.locStorage.getVal("bagStatusArr"));
    var unArrive = bagStatusArr[2];
    unArrive.sort(compare("ckiNumber"));
    if (unArrive.length > 0) {

      //下拉时加载新数据的数组
      var newArr = [];

      if (unArrive.length > 10) {
        //初始化10条数据
        for (var j = 0; j < 10; j++) {
          var obj = unArrive[j];
          newArr.push(obj)
        }
        loadData(newArr);
      } else {
        //10或10条以内全部加载出来
        loadData(unClaim);
      }
      //加载刷新控件
      var refresh = new initUpDownRefresh(1, 10);
      refresh.init(function(start, limit, type) {

        if (type == 1) {
          //1为上推加载更过数据
          var len = start + limit;
          //清空已经加载的数据
          newArr.length = 0;
          if (len >= unArrive.length) {
            //此时数据已经加载完了
            len = unArrive.length;
            toasts("数据已加载完毕...", 2000);
          }
          for (; start < len; start++) {
            //每次下拉
            var obj = unArrive[start];
            newArr.push(obj)
          }
          loadData(newArr, type);
        } else {
          //否则下拉刷新
          //清空已经加载的数据
          newArr.length = 0;
          for (; start < limit; start++) {
            var obj = unArrive[start];
            newArr.push(obj);
          }
          loadData(newArr);
        }
      });


    } else {
      notData("#BaggageList");
    }

  });
  var next = 0;
  function loadData(newArr, type) {
     var no =next++ *10;
    var template = "";
    newArr.forEach(function(item,index) {
      var serialNum = index + 1+no;
      if(!item.freLoyalLevelName){
        item.freLoyalLevelName = "暂无";
      }
      template += '<li class="listItems pt10 bor_bot2_D7D7D7 pb10 uot">' +
        '<section class="ub ub-pj lh20">' +
        '<div class="ub">' +
        '<p class="w15 h15 lh15 bor_3BBBD7 ml5 mr5 tx-c c3BBBD7"><small class="fs8">'+ serialNum +'</small></p>' +
        '<p class="w61 lh17">' + item.psnName + '</p>' +
        '</div>' +
        '<div class="ub pr5 w100">' +
        '<p class="mt2 icons_style icons_src_BT_status ml5 mr5"></p>' +
        '<p class="w45">行李状态:</p>' +
        '<p>未到达</p>' +
        '</div>' +
        '</section>' +
        '<section class="ub ub-pj lh20">' +
        '<div class="ub">' +
        '<p class="h_inherit icons_style icons_src_BT_card ml5 mr5"></p>' +
        '<p>行李号:</p>' +
        '<p class="pl5">' + item.bagNo + '</p>' +
        '</div>' +
        '<div class="ub pr5 w100">' +
        '<p class="h_inherit icons_style icons_src_BT_membershipCard ml5 mr5"></p>' +
        '<p class="w45">卡等级:</p>' +
        '<p>'+ item.freLoyalLevelName +'</p>' +
        '</div>' +
        '</section>' +
        '<section class="ub lh20">' +
        '<div class="ub">' +
        '<p class="h_inherit icons_style icons_src_BT_flight ml5 mr5"></p>' +
        '<p>登机序号:</p>' +
        '<p class="pl5">' + item.ckiNumber + '</p>' +
        '</div>' +
        '</section>' +
        '</li>'
    });
    if (type) {
      //不覆盖已经在加载的数据
      $("#BaggageList").append(template);
    } else {
      //覆盖已经在加载的数据
      $("#BaggageList").html(template);
    }

  }
</script>


</html>
